<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>注册LAU</title>


    
    <link rel="stylesheet" href="/Sys/css/layui.css">
    <link rel="stylesheet" href="/Sys/css/sign.css">
    
    <link rel="stylesheet" href="/Sys/js/css/modules/layui-icon-extend/iconfont.css">
     <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/Sys/css/font.css">
	<link rel="stylesheet" href="/Sys/css/xadmin.css">
	<link rel="stylesheet" href="/Sys/css/formSelects-v4.css" />
<script type="text/javascript"
	src="/Sys/js/jquery-3.3.1.min.js"></script>
    <script src="/Sys/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
        <script src="/Sys/js/formSelects-v4.js" type="text/javascript" charset="utf-8"></script>

</head>
<body class="layui-unselect lau-sign-body" style="padding-top: 0px " >

<form action="" class="layui-form">

    <div class="layui-form-item" >
     <div class="layui-inline">
        <label class="layui-form-label" ><i class="iconfont layui-icon-extend-bianhao" id="num" >教师工号</i></label>
        <div class="layui-input-block">
            <input type="text"  name="teachno"  id="teachno"  placeholder="请输入教师工号" autocomplete="off" class="layui-input" >
        </div>
 	</div>

    <div class="layui-inline">
        <label class="layui-form-label"><i class="iconfont layui-icon-extend-ziyuan"></i> 姓名</label>
        <div class="layui-input-block">
            <input type="text" name="name" placeholder="请输入姓名" autocomplete="off" class="layui-input" id="name">
        </div>
    </div>
 </div>   
    
    <div class="layui-form-item">
    <div class="layui-inline">
        <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i> 密码</label>
        <div class="layui-input-block">
            <input type="password" name="psw" placeholder="请输入密码" autocomplete="off" class="layui-input" id="psw">
        </div>
    </div>
    
    <div class="layui-inline">
        <label class="layui-form-label"><i class="iconfont layui-icon-extend-xingbie2"></i> 性别</label>
         <div class="layui-input-block">
      <input type="radio" name="sex" value="男" title="男" checked="">
      <input type="radio" name="sex" value="女" title="女">
    </div>
    </div>
    
    </div>
    
    
    
<div class="layui-form-item">
		
 <label class="layui-form-label">教授班级</label>
 <div class="layui-input-inline">
<select name="gra_class" xm-select="select6_5" xm-select-skin="danger"  lay-filter="gra_class">
    <option value="201601">201601</option>
    <option value="201602" >201602</option>
    <option value="201603">201603</option>
    <option value="201701" >201701</option>
    <option value="201702">201702</option>
    <option value="201703" >201703</option>
    <option value="201801" >201801</option>
    <option value="201802">201802</option>
    <option value="201803" >201803</option>
</select>
</div>


 <label class="layui-form-label">教授科目</label>
    <div class="layui-input-inline">
      <select name="course" id="course">
        <option value="">请选择科目</option>
        <option value="c001" >高数</option>
        <option value="c002">java</option>
        <option value="c003">linux</option>
        <option value="c004">javaWeb</option>
        <option value="c005">android</option>
        <option value="c006">数据结构</option>
        <option value="c007">数据库</option>
      </select>
    </div>

	</div>
  
  
  
    
      

    
	<div class="layui-form-item">
	<div class="layui-inline">
        <label class="layui-form-label"><i class="iconfont layui-icon-extend-QQ"></i>QQ</label>
        <div class="layui-input-block">
            <input type="text" id = "qq" name="qq" placeholder="请输入QQ" autocomplete="off" class="layui-input">
        </div>
    </div>
    
    
    
    

	<div class="layui-inline">
        <label class="layui-form-label"><i class="iconfont layui-icon-extend-icon-test"></i>手机号</label>
        <div class="layui-input-block">
            <input type="text" id="phone" name="phone" placeholder="请输入手机号" autocomplete="off" class="layui-input">
        </div>
    </div>
    </div>
    
    

    



	

  
<div class="layui-upload" style="margin-top: 20px;text-align:center">
 
    
    <button type="button" class="layui-btn layui-btn-primary"  id="test1"><i class="layui-icon">&#xe67c;</i>选择文件</button>
                  
   <img   id="demo1"  style="width:30px;height:30px;padding-left: 200px;">
</div>   
    <div class="layui-form-item lau-sign-other" style="margin-top: 20px;text-align:center">
        <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="updateTea" style="margin-right: 100px">提交</button>
       
    </div>

</form>

</body>
<script src="/Sys/lib/layui/layui.js"></script>
<script th:inline="javascript">
   $(function(){
	   
	   var num= [[${num}]];
		  $.ajax({
			  url:'getTeaByNum',
			  type:'POST',
			  data:{'num':num},
		  	  success:function(data){
		  		var datajson = JSON.parse(data)
		  		//alert(JSON.stringify(datajson.data[0].num))
		  		$("#teachno").val(datajson.data[0].teachno)
		  		$('#name').val(datajson.data[0].name)
		  		$('#psw').val(datajson.data[0].psw)
		  		$("input[name=sex][value='男']").attr("checked", datajson.data[0].sex == '男' ? true : false);
	          $("input[name=sex][value='女']").attr("checked",  datajson.data[0].sex == '女' ? true : false);
		  		$('#phone').val(datajson.data[0].phone)
		  		$('#qq').val(datajson.data[0].qq)		  		
		  		$('#phone').val(datajson.data[0].phone)
		  		
		  	  }
		  });
	   
	   
	   
	   
	   
	   
	   
	   
	   
	  var imgpath;	  
		var   url= ''
	   layui.use('upload', function(){
		   var $ = layui.jquery
		   ,upload = layui.upload;
		   //普通图片上传
		   var uploadInst = upload.render({
		     elem: '#test1'
		     ,url: 'uploadImg'
		    ,field:"photo"  //默认是file
		     ,before: function(obj){
		       //预读本地文件示例，不支持ie8
		       obj.preview(function(index, file, result){
		         $('#demo1').attr('src', result); //图片链接（base64）
		       });
		     }
		     ,done: function(res){
		       //如果上传失败
		       if(res.code > 0){
		         return layer.msg('上传失败');
		       }
		      imgpath=res.data;
		       
		     }
		     ,error: function(){
		       //演示失败状态，并实现重传
		       var demoText = $('#demoText');
		       demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
		       demoText.find('.demo-reload').on('click', function(){
		         uploadInst.upload();
		       });
		     }
		   });
   });
	   
		
		
		
		//全局定义一次, 加载formSelects
	    layui.config({
	        base: './js/' //此处路径请自行处理, 可以使用绝对路径
	    }).extend({
	        formSelects: 'formSelects-v4'
	    });
		
		
		
	  
	   
	    layui.use(['jquery','form','formSelects'], function() {
	    	   var formSelects = layui.formSelects;
	           layui.formSelects.config('select6_5', {direction: 'down'});
	           var form = layui.form;
	           //监听提交
	           form.on('submit(updateTea)', function(data) {
	               var updateJson= data.field;
	                updateJson.oldNum = num;
					updateJson.photo=imgpath;
					data=JSON.stringify(updateJson)
					$.ajax({
		               	 url : 'updateTea',
		                 data : data,
		                 type:'POST',
		                 contentType: 'application/json',
		                 success:function(data){
		                	 layer.msg("修改成功！",function(){
		                            
		                        });
		                 },
		                 error:function(args){
		                	 layer.msg("账号已经存在或者信息未填完整，注册失败！",function(){
		                         
		                     });
		                 }
		               	});
	              		
	           });
	       });   
   });
   
</script>
</html>